A recent trend in the manipulating and displaying of real-time 3D graphics is the increasing use of programmable graphics hardware. Such hardware is characterized by the presence of multiple programmable hardware stages, known as “shaders,” arranged in a pipeline. In contrast with “fixed,” or non-programmable hardware, each hardware stage in a programmable hardware pipeline can be programmed to perform a desired computational function, allowing for increased flexibility in the design of graphics algorithms. Examples of shaders include geometry shaders, vertex shaders, and pixel shaders.
When designing and debugging shader programs, a programmer may find it useful to access and view the runtime values of a shader's internal register and ALU (arithmetic logic unit) variables. This may be difficult, however, as there is usually no mechanism by which a shader's internal values can be transferred to an external location accessible to the programmer, such as an external memory module.
One possible approach is to purposefully assign the value of an internal variable of interest to the color of an outgoing pixel, send this pixel to the pixel blender block, wait until the pixel is drawn on a screen, and then inspect the color of the drawn pixel. While this approach takes advantage of an already existing pathway inside the shader, it has several disadvantages. First, it would be easier for the programmer if the value of the internal variable were displayed in its native format (e.g., floating point, integer, etc.), rather than as the color of a pixel on a screen. Second, the internal graphics pipeline might not be able to deliver the value of the pixel color unmodified to the screen buffer, leading to a problem with precision. For example, the pixel color could be 32-bit floating point, while the screen buffer for a particular monitor might only support 8-bit integer precision. In this case, it may be impossible to ascertain the actual value of an internal shader variable based solely on pixel color. Third, the above technique may be very cumbersome for a vertex shader, since the vertex shader is usually followed by a fragment shader. In this case, the fragment shader would need to be replaced by a “dummy” pass-through shader so that the values generated within the vertex shader can be passed unmodified to a screen buffer.
What is needed is a debugging tool having a simple user interface that allows programmers to easily and reliably ascertain the values of internal shader variables during runtime in programmable graphics hardware.